<template>
<div>
    <van-row>
        <van-col span="24"><hea /></van-col>
        <van-col span="3"><left /></van-col>
        <van-col span="21">
            <van-uploader :after-read="upload"/>
            <br/>
            <van-field></van-field>
            <van-button @click="download">查询</van-button>
              <van-button @click="download">导出</van-button>
                <van-button @click="showPopup">添加</van-button>
                <van-popup v-model:show="show">
                <van-field v-model="fromdata.name" />
                <van-field v-model="fromdata.code" />
                <van-field v-model="fromdata.pid" />
                <van-button @click="adddorang">添加</van-button>
              </van-popup>
        </van-col>
    </van-row>
    <!-- <shu @pid=getpid /> -->
</div>
  
</template>

<script>
import axios from 'axios'
import left from '../components/comm/left.vue'
import hea from '../components/comm/hea.vue'
// import shu from '../views/shu.vue'
import fileDownload from "js-file-download";
import { ref } from 'vue';


export default {
    data(){
        return{
            fromdata:{
                name:'',
                code:'',
                pid:this.pid
            }

        }
    },

    setup() {
    const show = ref(false);
    const showPopup = () => {
      show.value = true;
      
    };
    return {
      show,
      showPopup,
    };
  },
    components:{
        'left':left,
        'hea':hea,
        // 'shu':shu
    },
    methods:{

        upload(file){
            let fromdata = new FormData()
            fromdata.append('file',file.file)
            axios({url:'upload',method:'post',data:fromdata}).then(res=>{
                console.log(res);
            })
        },
        download(){
            axios({url:'download'}).then(res=>{
                fileDownload(res.data,'file.xls');
                console.log(res);
            })
        },
        addorang(){
            axios({url:'addzuzhi',method:'post',data:this.fromdata}.then(res=>{
                console.log(res);
            }))
        },
        // getpid(pid){
        //     this.pid=pid
        // }
    }


}
</script>

<style>

</style>